// 文章的相关接口
import request from '@/utils/request.js'

// 获取文章分类
export const getCateList = () => {
  return request({
    method: 'GET',
    url: '/my/cate/list',
  })
}

// 增加文章分类
export const addCateList = (obj) => {
  return request({
    method: 'POST',
    url: '/my/cate/add',
    data: obj,
  })
}

// 修改文章分类
export const updateCateList = (obj) => {
  return request({
    method: 'PUT',
    url: '/my/cate/info',
    data: obj,
  })
}

// 删除文章分类
export const delCateList = (id) => {
  return request({
    method: 'DELETE',
    url: '/my/cate/del?id=' + id,
  })
}

// 发布文章
export const uploadArticle = (fd) => {
  return request({
    method: 'POST',
    url: '/my/article/add',
    // 参数要的是表单对象, 不能写普通对象, axios内部会判断, 如果是表单对象, 传递的请求体会设置Content-Type: form-data与后端对应
    data: fd,
  })
}

// 获取文章列表
export const getArticlelist = (q) => {
  return request({
    method: 'GET',
    url: '/my/article/list',
    params: q,
  })
}

// 获取文章详情
export const getlistdetail = (id) => {
  return request({
    method: 'GET',
    url: '/my/article/info',
    params: {
      id,
    },
  })
}

// 删除文章列表的某条数据
export const dellist = (id) => {
  return request({
    method: 'DELETE',
    url: '/my/article/info',
    params: {
      id,
    },
  })
}
